package com.zl.id.controller;

import com.jfinal.kit.StrKit;
import com.zl.id.common.base.BaseController;
import com.zl.id.common.exception.AppException;
import com.zl.id.dao.model.SysUser;

public class LoginController extends BaseController {
	public void login() {
		String username = getPara("username");
		String password = getPara("password");
		Integer type = getParaToInt("type");
		SysUser userdb = SysUser.dao.findFirst("select * from sys_user where username = ? and type = ? ", username,type);
		if (userdb == null) {
			throw new AppException("User not Exist!");
		}

		String passwordDb = userdb.getPassword();
		if (StrKit.isBlank(passwordDb) || !passwordDb.equals(password)) {
			throw new AppException("Password is Not Correct!");
		}
		renderJsonResult(userdb);
	}
	
	
}
